﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FisheryPlatform.Search.Core.Analysis
{
    /// <summary>			
    /// Dictionary
    /// description:	the abstract class.
    /// create date:	2006-06-06
    /// author:			gwd
    /// </summary>
    public abstract class Dictionary
    {

        /// <summary>
        /// create an instance.
        /// </summary>
        /// <param name="name">dictionary name, as well as the directory name.</param>
        /// <param name="fullPath">dictionary direction full path</param>
        public Dictionary(string name, string fullPath, int minWordLength, int maxWordLength)
        {
            _name = name.ToLower();
            _fullPath = fullPath;
            _minWordLength = minWordLength;
            _maxWordLength = maxWordLength;
        }

        #region virtual Property

        /// <summary>
        /// dictionary name, read only.
        /// </summary>
        public virtual string FullPath
        {
            get { return _fullPath; }
        }
        private string _fullPath;

        /// <summary>
        /// dictionary name, read only.
        /// </summary>
        public virtual string Name
        {
            get { return _name; }
        }
        private string _name;

        /// <summary>
        /// min word length, read only.
        /// </summary>
        public virtual int MinWordLength
        {
            get { return _minWordLength; }
        }
        private int _minWordLength;

        /// <summary>
        /// max word length, read only.
        /// </summary>
        public virtual int MaxWordLength
        {
            get { return _maxWordLength; }
        }
        private int _maxWordLength;

        #endregion Property

        /// <summary>
        /// Load lexicons from dictionary path.
        /// </summary>
        protected internal abstract void LoadDictionary();

        /// <summary>
        /// Look up a word in a lexicon EXACTLY or not.
        /// </summary>
        /// <example>软件工程/软件工程师: false
        /// 软件工程师/软件工程师: true.</example>
        /// <param name="entry">a word</param>
        /// <returns>True/False</returns>
        public abstract bool Lookup(string entry);

        /// <summary>
        /// Look up the first part of a word in lexicons or not.
        /// </summary>
        /// <example>软件工程/软件工程师: true
        /// 软件工程师/软件工程师: true</example>
        /// <param name="entry">a word</param>
        /// <returns></returns>
        public abstract bool MaybeHaveEntry(string entry);

        /// <summary>
        /// Get a chinese character's frequence.
        /// </summary>
        /// <param name="character">a chinese character</param>
        /// <returns>frequence.</returns>
        public virtual long GetCharacterFreq(string character)
        {
            return 0;
        }
    }
}
